<template>
  <el-form ref="addData" :model="addData" label-width="120px">
    <el-form-item label="车位地址：">
      <el-input v-model="addData.address"></el-input>
    </el-form-item>
    <el-form-item label="车位号：">
      <el-input v-model="addData.number"></el-input>
    </el-form-item>
    <el-form-item label="产权信息：">
      <el-input v-model="addData.property"></el-input>
    </el-form-item>
    <el-form-item label="出租周期">
    <el-select v-model="addData.cycle" placeholder="请选择出租周期">
      <el-option label="两周" value="两周"></el-option>
      <el-option label="一个月" value="一个月"></el-option>
      <el-option label="两个月" value="两个月"></el-option>
      <el-option label="三个月" value="三个月"></el-option>
      <el-option label="半年" value="半年"></el-option>
    </el-select>
  </el-form-item>
    <el-form-item label="出租价格">
    <el-select v-model="addData.price" placeholder="请选择出租价格">
      <el-option label="500" value="500"></el-option>
      <el-option label="800" value="800"></el-option>
      <el-option label="1200" value="1200"></el-option>
      <el-option label="1500" value="1500"></el-option>
      <el-option label="2000" value="2000"></el-option>
    </el-select>
  </el-form-item>
    
    <el-form-item label="活动时间">
      <el-col :span="11">
        <el-date-picker
          type="date"
          placeholder="选择日期"
          v-model="addData.date1"
          style="width: 100%"
        ></el-date-picker>
      </el-col>
      <el-col class="line" :span="2">-</el-col>
      <el-col :span="11">
        <el-time-picker
          placeholder="选择时间"
          v-model="addData.date2"
          style="width: 100%"
        ></el-time-picker>
      </el-col>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="myaddParking()">立即添加</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const {mapState,mapMutations,mapGetters,mapActions,} = createNamespacedHelpers("parkings");
export default {
  data() {
    return {
      addData: {
        address: "",
        number: "",
        property: "",
        cycle: "",
        price: "",
        date1:'',
        date2:'',
        lessorsId:localStorage.getItem('_id')
      },
    };
  },
  methods: {
    ...mapActions(["addParking"]),
    async myaddParking() {
      const data = await this.addParking(this.addData);
      if (data.status) {
        alert(data.message);
        this.$router.push("/System/ParkingList");
      }
    },
  },
};
</script>